﻿using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Autofac;
using Volo.Abp.BackgroundWorkers.Quartz;
using Volo.Abp.Modularity;
using Volo.Abp.Caching.StackExchangeRedis;
using Volo.Abp.Caching;
using PHMEE.BackgroundServices.Videos;
using Autofac.Core;
using Video.BackgroundServices.BusinessInterface;
using Video.BackgroundServices.BusinessService;

namespace PHMEE.BackgroundServices
{
    [DependsOn(
        typeof(AbpAutofacModule),
        typeof(AbpBackgroundWorkersQuartzModule),
        typeof(AbpCachingStackExchangeRedisModule))]

    public class PHMEEBackgroundServicesModule : AbpModule
    {
        public override void ConfigureServices(ServiceConfigurationContext context)
        {
            context.Services.AddHostedService<PHMEEBackgroundServicesHostedService>();

            //// 获取Configuration
            var configuration = context.Services.GetConfiguration();

            Configure<AbpDistributedCacheOptions>(options => { options.KeyPrefix = "PHMEE_BackgroundServices:"; });

            // 绑定 SerialSettings 配置
            var redisConfiguration = configuration.GetSection("Redis")["Configuration"];

            context.Services.AddHostedService<VideoControlsWorker>();

            context.Services.AddTransient<IMqttExtendManager, MqttExtendManager>();
        }
    }
}
